<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Web_configuration extends MX_Controller {

	public function __construct() {
		parent::__construct();

		$this->load->model('admin_settings_model');
		$this->load->model(array('admin_commoncall','admin_settings_model'));
		$this->load->model('settings_model');
			
		$this->template->set_theme('admin');
		$this->template->set_layout('default');
		$this->template->set_partial('side_menu','layouts/side_menu');
		$this->template->set_partial('nav_bar','layouts/nav_bar');
		$this->template->set_partial('footer','footer/footer');


	}

	public function index(){

		$data['settings']['all'] = $this->settings_model->getSettings();
		$this->template->build('settings/web_settings',$data);

	}

	public function getSetting(){
		$data['settings']['all'] = $this->settings_model->getSettings();
		if ($this->input->post('website_settings')) {
			$this->form_validation->set_rules('website_settings', 'website_settings', 'required|xss_clean');
			$settingsID = $this->input->post('website_settings');

			if ($this->form_validation->run()) {
				$data['row']['info'] = $this->admin_settings_model->get_web_settings($settingsID);
				//var_dump($data['settings']['info']);
				//die();
				$this->template->title('Dashboard', $this->settings_model->get_setting('webtitle'))
				->set_partial('nav_bar','layouts/nav_bar')
				->set_partial('side_menu','layouts/side_menu')
				->build('settings/web_settings', $data);
			} else {
				$this->session->set_flashdata('message', 'Invalid!');
				redirect('secure/settings/web_configuration', $data);
			}
		}
	}

	function update() {
		
		//if ($this->input->post('update_settings')) {
			//$this->form_validation->set_rules('website_settings', 'website_settings', 'required|xss_clean');
			$this->form_validation->set_rules('web_detail', 'web_detail', 'required|xss_clean');
			$this->form_validation->set_rules('web_id', 'web_id', 'required|xss_clean');

				
			$settingsID = trim($this->input->post('web_id'));
			$settings_description = $this->input->post('web_detail');
			
				
			if ($this->form_validation->run()) {
				$this->admin_settings_model->update_settings($settings_description, $settingsID);
				$this->session->set_flashdata('message', 'Web Configuration Updated Sucessfully');
				redirect('secure/settings/web_configuration');
			}
		//}
		$this->session->set_flashdata('message', 'Please Choose a Configure!');
		redirect('secure/settings/web_configuration/');
	}

}
/* End of file*/